<?
require("config.php");

$location_status .= "| Edit";
$show_backnav = "menu";
$menuname = NULL;
$menutarget = NULL;

if (NULL!=$action){

	$Date = "$Year-$Month-$Day";

	if ($Picture_name=="" || $Picture_name==NULL) $Picture_name=$old_Picture;

	if ($remove_Picture=="ture") $Picture_name=NULL;

   $field = array(
	"date", 
	"type", 
	"subject", 
	"details",
	"picture",
    "target",
	);


   $content = array(
	$Date,
	$Type,
	$Subject,
	$Details,
	$Picture_name,
	$Target,
	);

	$exp = "id=$id";

   myUpdate($table,$field,$content,$exp);

	$dir = "med_showcase/";

	myUpload($Picture,$Picture_name,$dir);


   header("location:" . $rela_path . "share/msg.php?v=60");

   exit();

}else{

  if (!checkRecord($table,$id)){

	header("location:" . $rela_path . "share/msg.php?v=9002");

	exit();
  
  }

}


$Query = "SELECT 
code,
date,
type,
subject, 
details,
picture,
target 
FROM $table WHERE id=$id LIMIT 1";

$r=myQuery($Query);

$Code=$r[0][0];
$Date=$r[0][1];
$Type=$r[0][2];
$Subject=$r[0][3];
$Details=$r[0][4];
$Picture=$r[0][5];
$Target=$r[0][6];

$Query = "select code, name from med_showcase_type";
$types = myQuery($Query);

require($rela_path . "inc/header.php");
require($rela_path . "bin/date.php");

?>



<form action="" method="post" enctype="multipart/form-data" name="form1">
<input name="action" type="hidden" value="edit">
<input name="id" type="hidden" value="<?print($id)?>">
<input name="old_Picture" type="hidden" value="<?print($Picture)?>">




<table width="95%" border="0" align="center">
  <tr> 
    <td valign="top"> <table border="0" cellspacing="5" cellpadding="1">
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td class="tdheader">Code : </td>
            <td><?print($Code)?></td>
          </tr>
          <tr> 
            <td class="tdheader">Date :</td>
            <td><?print(FFPdate($Date))?></td>
          </tr>
          <tr>
            <td class="tdheader">Type :</td>
            <td><select class="select" name="Type">
<!--<option selected>SELECT</option>-->
<?
for ($i=0;$i<count($types);$i++){

	$active = NULL;
	if ($types[$i][1] == $Type) $active = "SELECTED";

	print("<option value='" . $types[$i][1] . "' $active>" . $types[$i][1] . "</option>");
}

?>
</select></td>
          </tr>
          <tr> 
            <td class="tdheader">Subject :</td>
            <td><input type="text" class="text" name="Subject" size="56" value="<?print($Subject)?>"></td>
          </tr>
          <tr> 
            <td class="tdheader">Details : </td>
            <td><textarea class="text" name="Details" cols="55" rows="20"><?print($Details)?></textarea></td>
          </tr>
          <tr> 
            <td class="tdheader">Picture :</td>
            <td> 
              <?loadImage($Picture,$rela_path . $PIC_DIR. $table . "/")?>
              <?removeImage($Picture,"remove_Picture")?>
              <input type="file" class="text" name="Picture" size="45"> </td>
          </tr>
          <tr> 
            <td class="tdheader">Target :</td>
            <td> <input type="text" class="text" name="Target" size="56" value="<?print($Target)?>"></td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td><input type="image" src="../../images/bt_cancel.gif" onClick="Redirect('menu.php',1);return false;"> 
              <input type="image" src="../../images/bt_save.gif"> </td>
          </tr>
          <tr> 
            <td>&nbsp;</td>
            <td>&nbsp;</td>
          </tr>
        </table>
    </td>

  </tr>
</table>
<br>
<br>
<br>


</form>

<?
require($rela_path . "inc/footer.php");
?>
